<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            let age = Number(window.prompt("请输入年龄"));
            if (age > 0 && age < 18) /*满足条件输出，未满足执行下面代码*/{
                alert("未成年人");
            }
            if (age >= 18 && age < 60) {
                alert("成年人");
            }
            if (age >= 60) {
                alert("老年人");
            }
            if (age < 0 || Boolean(age) === false) {
                alert("输入错误！请重新输入！")
            }//NaN转换为布尔值为false
        </script>
    </body>
</html>
